package com.hcl.security.utils;

public class Result<T> {

	private Integer code;// 状态码
	private String message;// 返回消息
	private T data;// 返回数据

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	public static <T> Result<T> ok(T data) {
		Result<T> result = new Result<>();
		result.setCode(200);
		result.setMessage("成功");
		result.setData(data);
		return result;
	}

	public static <T> Result<T> error(Integer code, String message) {
		Result<T> result = new Result<>();
		result.setCode(code);
		result.setMessage(message);
		return result;
	}
}
